# Contributor: Michał Polański <michal@polanski.me>
# Maintainer: Michał Polański <michal@polanski.me>
pkgname=py3-pytest-benchmark
_pkgname=pytest-benchmark
pkgver=3.4.1
pkgrel=1
pkgdesc="pytest fixture for benchmarking code"
url="https://github.com/ionelmc/pytest-benchmark"
arch="noarch"
license="BSD-2-Clause"
depends="python3 py3-pytest py3-py-cpuinfo"
makedepends="py3-setuptools"
checkdepends="py3-pytest-xdist py3-freezegun py3-pygal py3-elasticsearch"
source="https://github.com/ionelmc/pytest-benchmark/archive/v$pkgver/pytest-benchmark-$pkgver.tar.gz
	python-3.10.patch"
builddir="$srcdir/$_pkgname-$pkgver"

build() {
	python3 setup.py build
}

check() {
	# install the package to test_install directory for testing
	python3 setup.py install --root="$builddir"/test_install

	# disable three tests that require aspectlib (needs packaging)
	# last test fails when run inside a git repository, see: https://github.com/ionelmc/pytest-benchmark/issues/163
	local sitedir=$(python3 -c "import site; print(site.getsitepackages()[0])")
	PYTHONPATH="$builddir"/test_install/"$sitedir" PATH="$builddir"/test_install/usr/bin:"$PATH" \
		pytest -v tests \
		--deselect tests/test_with_testcase.py::TerribleTerribleWayToWritePatchTests::test_foo2 \
		--deselect tests/test_with_weaver.py::test_weave_fixture \
		--deselect tests/test_with_weaver.py::test_weave_method \
		--deselect tests/test_utils.py::test_parse_elasticsearch_storage \
		--deselect tests/test_cli.py::test_help_compare \
		--deselect tests/test_cli.py::test_help_list \
		--deselect tests/test_cli.py::test_help_command \
		--deselect tests/test_cli.py::test_help
}

package() {
	python3 setup.py install --prefix=/usr --root="$pkgdir" --skip-build
}

sha512sums="
54fb5e3a176578b3c8f339878c7a9d047a0785befcbba42bb68c34b4b636d9b6f6a2097b36c5eefbbcf1a91f943bdae762c7978a0dba1af53514052f513ef4c5  pytest-benchmark-3.4.1.tar.gz
13cd0220e32d193c21d109a6d817c4a27d88f9032d4af16805ba7d0b34385af5f94d26294d62893c3876350e7afe0aedb41e5c4c65252dfe2e789f1d36877828  python-3.10.patch
"
